/*
 * File: Ctrl.h
 *
 * Code generated for Simulink model 'Ctrl'.
 *
 * Model version                  : 1.180
 * Simulink Coder version         : 8.2 (R2012a) 29-Dec-2011
 * TLC version                    : 8.2 (Dec 29 2011)
 * C/C++ source code generated on : Sat May 05 21:57:05 2012
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Texas Instruments->C2000
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#ifndef RTW_HEADER_Ctrl_h_
#define RTW_HEADER_Ctrl_h_
#ifndef Ctrl_COMMON_INCLUDES_
# define Ctrl_COMMON_INCLUDES_
#include <stddef.h>
#include <math.h>
#include <string.h>
#include "rtwtypes.h"
#endif                                 /* Ctrl_COMMON_INCLUDES_ */

#include "Ctrl_types.h"

/* Macros for accessing real-time model data structure */
#ifndef rtmGetErrorStatus
# define rtmGetErrorStatus(rtm)        ((rtm)->errorStatus)
#endif

#ifndef rtmSetErrorStatus
# define rtmSetErrorStatus(rtm, val)   ((rtm)->errorStatus = (val))
#endif

/* Block signals (auto storage) */
typedef struct {
  real32_T PWM1;                       /* '<S1>/Merge' */
  real32_T PWM2;                       /* '<S1>/Merge' */
  uint32_T AMode;                      /* '<S1>/Chart' */
  boolean_T Failed;                    /* '<S1>/Chart' */
  boolean_T CtrlOff;                   /* '<S1>/Chart' */
  boolean_T CtrlPWMThrust;             /* '<S1>/Chart' */
  boolean_T CtrlAlt;                   /* '<S1>/Chart' */
} BlockIO_Ctrl;

/* Block states (auto storage) for system '<Root>' */
typedef struct {
  real32_T Integrator_DSTATE;          /* '<S12>/Integrator' */
  real32_T Integrator_DSTATE_n;        /* '<S8>/Integrator' */
  uint16_T is_active_c1_Ctrl;          /* '<S1>/Chart' */
  uint16_T is_Online;                  /* '<S1>/Chart' */
  uint16_T is_active_SystemLogic;      /* '<S1>/Chart' */
  uint16_T is_SystemLogic;             /* '<S1>/Chart' */
  boolean_T PWMThrust_MODE;            /* '<S1>/PWMThrust' */
  boolean_T PWMThrust1_MODE;           /* '<S1>/PWMThrust1' */
} D_Work_Ctrl;

/* External inputs (root inport signals with auto storage) */
typedef struct {
  uint32_T Mode;                       /* '<Root>/Mode' */
  boolean_T AckErrr;                   /* '<Root>/AckErrr' */
  real32_T PWMSet;                     /* '<Root>/PWMSet' */
  real32_T YawRef;                     /* '<Root>/YawRef' */
  real32_T dYaw;                       /* '<Root>/dYaw' */
  real32_T MagY;                       /* '<Root>/MagY' */
  real32_T MagZ;                       /* '<Root>/MagZ' */
} ExternalInputs_Ctrl;

/* External outputs (root outports fed by signals with auto storage) */
typedef struct {
  uint32_T ActualMode;                 /* '<Root>/ActualMode' */
  boolean_T Failed;                    /* '<Root>/Failed' */
  real32_T PWM1;                       /* '<Root>/PWM1' */
  real32_T PWM2;                       /* '<Root>/PWM2' */
} ExternalOutputs_Ctrl;

/* Parameters (auto storage) */
struct Parameters_Ctrl_ {
  real32_T PWMs_Y0[2];                 /* Computed Parameter: PWMs_Y0
                                        * Referenced by: '<S4>/PWMs'
                                        */
  real32_T Constant1_Value;            /* Computed Parameter: Constant1_Value
                                        * Referenced by: '<S4>/Constant1'
                                        */
  real32_T Constant2_Value;            /* Computed Parameter: Constant2_Value
                                        * Referenced by: '<S4>/Constant2'
                                        */
  real32_T PWMs_Y0_i[2];               /* Computed Parameter: PWMs_Y0_i
                                        * Referenced by: '<S5>/PWMs'
                                        */
  real32_T ProportionalGain_Gain;      /* Computed Parameter: ProportionalGain_Gain
                                        * Referenced by: '<S9>/Proportional Gain'
                                        */
  real32_T Saturation_UpperSat;        /* Computed Parameter: Saturation_UpperSat
                                        * Referenced by: '<S9>/Saturation'
                                        */
  real32_T Saturation_LowerSat;        /* Computed Parameter: Saturation_LowerSat
                                        * Referenced by: '<S9>/Saturation'
                                        */
  real32_T ProportionalGain_Gain_h;    /* Computed Parameter: ProportionalGain_Gain_h
                                        * Referenced by: '<S8>/Proportional Gain'
                                        */
  real32_T Integrator_gainval;         /* Computed Parameter: Integrator_gainval
                                        * Referenced by: '<S8>/Integrator'
                                        */
  real32_T Integrator_IC;              /* Computed Parameter: Integrator_IC
                                        * Referenced by: '<S8>/Integrator'
                                        */
  real32_T Saturation_UpperSat_h;      /* Computed Parameter: Saturation_UpperSat_h
                                        * Referenced by: '<S8>/Saturation'
                                        */
  real32_T Saturation_LowerSat_i;      /* Computed Parameter: Saturation_LowerSat_i
                                        * Referenced by: '<S8>/Saturation'
                                        */
  real32_T IntegralGain_Gain;          /* Computed Parameter: IntegralGain_Gain
                                        * Referenced by: '<S8>/Integral Gain'
                                        */
  real32_T Constant_Value;             /* Computed Parameter: Constant_Value
                                        * Referenced by: '<S8>/Constant'
                                        */
  real32_T PWMs_Y0_j[2];               /* Computed Parameter: PWMs_Y0_j
                                        * Referenced by: '<S6>/PWMs'
                                        */
  real32_T ProportionalGain_Gain_f;    /* Computed Parameter: ProportionalGain_Gain_f
                                        * Referenced by: '<S13>/Proportional Gain'
                                        */
  real32_T Saturation_UpperSat_e;      /* Computed Parameter: Saturation_UpperSat_e
                                        * Referenced by: '<S13>/Saturation'
                                        */
  real32_T Saturation_LowerSat_o;      /* Computed Parameter: Saturation_LowerSat_o
                                        * Referenced by: '<S13>/Saturation'
                                        */
  real32_T ProportionalGain_Gain_a;    /* Computed Parameter: ProportionalGain_Gain_a
                                        * Referenced by: '<S12>/Proportional Gain'
                                        */
  real32_T Integrator_gainval_n;       /* Computed Parameter: Integrator_gainval_n
                                        * Referenced by: '<S12>/Integrator'
                                        */
  real32_T Integrator_IC_e;            /* Computed Parameter: Integrator_IC_e
                                        * Referenced by: '<S12>/Integrator'
                                        */
  real32_T Saturation_UpperSat_m;      /* Computed Parameter: Saturation_UpperSat_m
                                        * Referenced by: '<S12>/Saturation'
                                        */
  real32_T Saturation_LowerSat_g;      /* Computed Parameter: Saturation_LowerSat_g
                                        * Referenced by: '<S12>/Saturation'
                                        */
  real32_T IntegralGain_Gain_o;        /* Computed Parameter: IntegralGain_Gain_o
                                        * Referenced by: '<S12>/Integral Gain'
                                        */
  real32_T Constant_Value_f;           /* Computed Parameter: Constant_Value_f
                                        * Referenced by: '<S12>/Constant'
                                        */
  real32_T Bias_Bias;                  /* Computed Parameter: Bias_Bias
                                        * Referenced by: '<S2>/Bias'
                                        */
  real32_T Bias1_Bias;                 /* Computed Parameter: Bias1_Bias
                                        * Referenced by: '<S2>/Bias1'
                                        */
};

/* Real-time Model Data Structure */
struct RT_MODEL_Ctrl {
  const char_T * volatile errorStatus;
};

/* Class declaration for model Ctrl */
class CtrlModelClass {
  /* public data and function members */
 public:
  /* External inputs */
  ExternalInputs_Ctrl Ctrl_U;

  /* External outputs */
  ExternalOutputs_Ctrl Ctrl_Y;

  /* Model entry point functions */

  /* model initialize function */
  void initialize();

  /* model step function */
  void step();

  /* model terminate function */
  void terminate();

  /* Constructor */
  CtrlModelClass();

  /* Destructor */
  ~CtrlModelClass();

  /* Real-Time Model get method */
  RT_MODEL_Ctrl * getRTM() const;

  /* private data and function members */
 private:
  /* Tunable parameters */
  Parameters_Ctrl Ctrl_P;

  /* Block signals */
  BlockIO_Ctrl Ctrl_B;

  /* Block states */
  D_Work_Ctrl Ctrl_DWork;

  /* Real-Time Model */
  RT_MODEL_Ctrl Ctrl_M_;

  /* Real-Time Model pointer */
  RT_MODEL_Ctrl *Ctrl_M;

  /* private member function(s) for subsystem '<Root>' */
  void Ctrl_SetOutputs(real_T state);
};

/*-
 * The generated code includes comments that allow you to trace directly
 * back to the appropriate location in the model.  The basic format
 * is <system>/block_name, where system is the system number (uniquely
 * assigned by Simulink) and block_name is the name of the block.
 *
 * Note that this particular code originates from a subsystem build,
 * and has its own system numbers different from the parent model.
 * Refer to the system hierarchy for this subsystem below, and use the
 * MATLAB hilite_system command to trace the generated code back
 * to the parent model.  For example,
 *
 * hilite_system('R10Model/Ctrl')    - opens subsystem R10Model/Ctrl
 * hilite_system('R10Model/Ctrl/Kp') - opens and selects block Kp
 *
 * Here is the system hierarchy for this model
 *
 * '<Root>' : 'R10Model'
 * '<S1>'   : 'R10Model/Ctrl'
 * '<S2>'   : 'R10Model/Ctrl/Angleconverter'
 * '<S3>'   : 'R10Model/Ctrl/Chart'
 * '<S4>'   : 'R10Model/Ctrl/Off'
 * '<S5>'   : 'R10Model/Ctrl/PWMThrust'
 * '<S6>'   : 'R10Model/Ctrl/PWMThrust1'
 * '<S7>'   : 'R10Model/Ctrl/Angleconverter/MATLAB Function'
 * '<S8>'   : 'R10Model/Ctrl/PWMThrust/Discrete PID Controller'
 * '<S9>'   : 'R10Model/Ctrl/PWMThrust/Discrete PID Controller1'
 * '<S10>'  : 'R10Model/Ctrl/PWMThrust/MATLAB Function'
 * '<S11>'  : 'R10Model/Ctrl/PWMThrust/Discrete PID Controller/Clamping circuit'
 * '<S12>'  : 'R10Model/Ctrl/PWMThrust1/Discrete PID Controller'
 * '<S13>'  : 'R10Model/Ctrl/PWMThrust1/Discrete PID Controller1'
 * '<S14>'  : 'R10Model/Ctrl/PWMThrust1/Discrete PID Controller/Clamping circuit'
 */
#endif                                 /* RTW_HEADER_Ctrl_h_ */

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
